package com.itheima.info.system.manager.service;

import com.itheima.info.system.manager.dao.IBaseTeacherDao;
import com.itheima.info.system.manager.domain.Teacher;
import com.itheima.info.system.manager.factory.Factory;

import java.util.ArrayList;

public class TeacherSerivce implements IBaseTeacherService {
    private IBaseTeacherDao teacherDao = Factory.getTeacherDao();

    @Override
    public void add(Teacher teacher) {
        teacherDao.add(teacher);
    }

    @Override
    public void delete(String sid) {
        teacherDao.delete(sid);
    }

    @Override
    public void updata(String sid, Teacher teacher) {
        teacherDao.updata(sid, teacher);
    }

    @Override
    public ArrayList<Teacher> findAll() {
        return teacherDao.findAll();
    }

    @Override
    public boolean isEmpty() {
        ArrayList<Teacher> teachers = teacherDao.findAll();
        return teachers.size() == 0;
    }

    @Override
    public boolean isExist(String sid) {
        int index = teacherDao.getIndexBySid(sid);
        return index != -1;
    }
}
